<!DOCTYPE html>
<html lang="en">
<head>
    <title>login</title>
    <script type="text/javascript" src="../static/jquery.min.js"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style>
        div{
            padding:10px 10px 0 10px;
        }
    </style>
</head>
<body>
<div>
    <table>
        <tr>
            <td>邮件</td>
            <td><input type="text" id="email"/></td>
            <td></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="text" id="password"/></td>
            <td></td>
        </tr>
        <tr>
            <td> <input type="button" value="登录" id="submit"/></td>
            <td><a href="/static/register.html" target="_blank">注册新账号</a></td>
            <td></td>
        </tr>
    </table>


</div>
</div>
</body>
<script>
    $("#submit").click(function () {
        let email = $("#email").val();
        let password = $("#password").val();
        $.ajax({
            url: '/api/user/login/'+email+'/'+password,
            type: 'GET',
            contentType: 'application/x-www-form-urlencoded',
            success: function (data) {
                if(data == email){
                    window.open("/static/welcome.html?email="+email)
                }else{
                    alert(data)
                }
            },
            error:function () {
                alert("request error");
            }
        })
    })
</script>
</html>